import 'package:json_annotation/json_annotation.dart';

part 'role.g.dart';

@JsonSerializable(explicitToJson: true)
class Role extends Object {
  @JsonKey(name: 'roleId')
  int roleId;

  @JsonKey(name: 'roleName')
  String roleName;

  @JsonKey(name: 'storeId')
  int storeId;

  List<Permissions> permissions;

  Role(
    this.roleId,
    this.roleName,
    this.storeId,
  );

  factory Role.fromJson(Map<String, dynamic> srcJson) => _$RoleFromJson(srcJson);

  Map<String, dynamic> toJson() => _$RoleToJson(this);
}

@JsonSerializable(explicitToJson: true)
class Permissions extends Object {
  @JsonKey(name: 'apiUri')
  String apiUri;

  @JsonKey(name: 'menuCode')
  String menuCode;

  @JsonKey(name: 'menuName')
  String menuName;

  @JsonKey(name: 'menuType')
  int menuType;

  @JsonKey(name: 'parentId')
  int parentId;

  @JsonKey(name: 'permissionCode')
  String permissionCode;

  @JsonKey(name: 'permissionId')
  int permissionId;

  @JsonKey(name: 'permissionName')
  String permissionName;

  @JsonKey(name: 'permissionSelect')
  bool permissionSelect;

  @JsonKey(name: 'type')
  int type;

  @JsonKey(name: 'userPermission')
  List<Permissions> userPermission;

  Permissions(
    this.apiUri,
    this.menuCode,
    this.menuName,
    this.menuType,
    this.parentId,
    this.permissionCode,
    this.permissionId,
    this.permissionName,
    this.permissionSelect,
    this.type,
    this.userPermission,
  );

  factory Permissions.fromJson(Map<String, dynamic> srcJson) => _$PermissionsFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PermissionsToJson(this);
}
